package com.qhgrain.demo.service;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service("DemoService")
public class RestTemplateDemoService {
	
	@Autowired
	private RestTemplate restTemplate;
	
	public  String  getForObject(String url){
		String message = restTemplate.getForObject(url, String.class); 
		return message;
	}
	public  String  getForObject(String url,Map params){
		String message= restTemplate.getForObject(url, String.class, params); 
		return message;
	}
	
	
	public  String  postForObject(String url){
		ResponseEntity<String> message = restTemplate.postForEntity(url, null, String.class);
		return message.getBody();
	}
	
	public  String  postForObject(String url,Map params){
		String message= restTemplate.getForObject(url, String.class, params); 
		return message;
	}
	
	public void delete(String url){
		restTemplate.delete(url); 
	}	
	
}
